package com.test.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class MainController extends AbstractController {
	
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest req,
			HttpServletResponse res) throws Exception {
		String pageType = req.getParameter("page") != null ?
						req.getParameter("page") : "";

		Map<String, Object> mainData = new HashMap<String, Object>();

		if (pageType.equals("") || pageType.equals("main")){
			String aId = req.getParameter("aId");
			int authorId = aId != null ? Integer.parseInt(aId) : 0;
			mainData.put("authorId", authorId);
			return new ModelAndView("main", mainData);
		}
		return null;
	}

}
